<template>
  <div class="entrance-list">
    <el-table
            :data="tableData"
            border
            style="width: 100%">
      <el-table-column
              label="照片"
              width="160" align="center">
        <template slot-scope="scope">
          <div>
            <img :src="scope.row.photoSmall" style="width: 140px" alt="">
          </div>
        </template>
      </el-table-column>
      <el-table-column
              prop="name"
              label="姓名"
              width="180" align="center">
      </el-table-column>
      <el-table-column
              prop="phone"
              label="电话"
              width="180" align="center">
      </el-table-column>
      <el-table-column
              prop="buildingName"
              label="楼栋" align="center">
      </el-table-column>
      <el-table-column
              prop="unitName"
              label="单元" align="center">
      </el-table-column>
      <el-table-column
              label="进入方式" align="center">
        <template slot-scope="scope">
          <div>
            <span>{{base.getEnterType ? base.getEnterType('enterType', scope.row.type) : ''}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
              prop="insertDate"
              label="时间" align="center">
      </el-table-column>
    </el-table>
    <el-pagination background class="el-page-body"
                   @current-change="initData"
                   :current-page.sync="page.page"
                   :page-size="page.limit"
                   layout="total, prev, pager, next, jumper"
                   :total="totalCount">
    </el-pagination>
  </div>
</template>
<script>
import base from '../../../../assets/scripts/base/base'

export default {
  name: 'entranceGuardList',
  data () {
    return {
      tableData: [],
      page: {
        page: 1,
        limit: 5
      },
      totalCount: 1,
      base: base()
    }
  },
  created: function () {
    this.initData()
    console.log(this)
  },
  methods: {
    initData: function () {
      console.log(this.$route)
      let url = this.$base.getUrl('getCarPark')
      let params = {
        url: url,
        data: this.page
      }

      this.$store.dispatch('postForm', params).then((res) => {
        const { list, totalCount } = res.content
        this.tableData = list
        this.totalCount = totalCount
      })
    }
  }
}
</script>
<style lang="less" scoped>
  .entrance-list {
    padding: 15px 20px;
  }

  .el-page-body {
    margin-top: 20px;
  }
</style>
